Skip to content

feat: Add Kraftfile schema v0.7 support#2776

Open
ijaidev wants to merge 8 commits intounikraft:stagingfrom
ijaidev:kraftfile-schema07-support
Open

feat: Add Kraftfile schema v0.7 support#2776
ijaidev wants to merge 8 commits intounikraft:stagingfrom
ijaidev:kraftfile-schema07-support

Conversation

@ijaidev
Copy link
Copy Markdown
Contributor

@ijaidev ijaidev commented Apr 8, 2026

Add Kraftfile schema v0.7 support

Prerequisite checklist

Description of changes

This PR adds Kraftfile schema v0.7 support across project loading,
template resolution, runtime handling, and packaging flows.

  • Dispatch project loading by Kraftfile spec version and map v0.7
    documents into the existing application model.

  • Resolve v0.7 templates before application mapping so template
    defaults merge correctly while project fields continue to take
    precedence.

  • Preserve full OCI runtime references during parsing and runtime
    package lookup.

  • Keep v0.7 projects read-only for mutation paths that still depend
    on the legacy loader.

  • Normalize target artifact names and honor the configured project
    output directory during build flows.

  • Carry rootfs and ROM filesystem metadata through application
    loading, initrd generation, packaging, and OCI manifest creation.

  • Extend test coverage around spec dispatch, template behavior,
    runtime references, output paths, and filesystem metadata
    propagation.

    Issue Add kraftkit support for v0.7 kraftfile schema #2682

@craciunoiuc
Copy link
Copy Markdown
Member

Hey, the format is type(location) not [type](location) can you switch them please? Thanks. For example: gomod(deps): ...
image

@ijaidev ijaidev force-pushed the kraftfile-schema07-support branch from 2c18c69 to a4facbe Compare April 8, 2026 12:02
@ijaidev ijaidev changed the title Kraftfile schema 0.7 support feat: Add Kraftfile schema v0.7 support Apr 8, 2026
@ijaidev
Copy link
Copy Markdown
Contributor Author

ijaidev commented Apr 8, 2026

Done

Copy link
Copy Markdown
Member

@craciunoiuc craciunoiuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one comment my side, otherwise looks pretty good

needs thorough testing though 😅

Comment thread unikraft/app/project_loader.go Outdated
@craciunoiuc
Copy link
Copy Markdown
Member

also try doing a rebase when you have time

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Kraftfile schema v0.7 support by introducing a dedicated project loader path, template pre-resolution/merge, and updated runtime/rootfs/ROM plumbing so v0.7 projects can be loaded and built/packaged consistently across CLI workflows.

Changes:

  • Add v0.7 project loading/dispatch (including template resolution before mapping) and record loader/spec metadata on the resulting Application.
  • Update runtime reference parsing to preserve full OCI references and adjust runtime package lookup accordingly; add unit tests.
  • Thread rootfs/ROM filesystem metadata (formats + paths) through targets, initrd generation, packagers, and OCI packaging; normalize build output paths and artifact naming.

Reviewed changes

Copilot reviewed 35 out of 36 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
unikraft/type.go Adds shared project-name normalization helper.
unikraft/target/target.go Normalizes target artifact/config names; changes ROM type to v0.7 FS descriptors.
unikraft/runtime/transform.go Uses improved runtime ref splitting for schema strings.
unikraft/runtime/runtime.go Adds query/reference helpers; improves OCI ref parsing behavior.
unikraft/runtime/runtime_test.go Adds coverage for runtime ref parsing + schema transform behavior.
unikraft/app/volume/transform.go Adds support for parsing volume mode.
unikraft/app/template_resolver.go New resolver for v0.7 template pull/parse/merge semantics.
unikraft/app/project_v07.go New v0.7 loader mapping Kraftfile v0.7 into existing application model.
unikraft/app/project_v07_test.go New tests for spec dispatch, template merge, runtime refs, outdir, fs metadata, volumes.
unikraft/app/project_loader.go Introduces spec sniffing + dispatch between legacy and v0.7 loaders.
unikraft/app/project.go Refactors legacy loader into newLegacyProjectFromOptions; records loader/spec version.
unikraft/app/normalize.go Reuses new unikraft.NormalizeProjectName.
unikraft/app/loader_kind.go Adds loader kind enum + mutation-not-supported error.
unikraft/app/loader.go Updates parsing for rootfs type + ROMs to v0.7 FS descriptors.
unikraft/app/application_options.go Extends application options with loader/spec; changes fs/rom option types.
unikraft/app/application.go Extends Application API for loader/spec; makes v0.7 template pre-merged; updates fs/rom types.
packmanager/pack_options.go Switches ROMs from []string to []FS.
oci/pack.go Updates ROM handling to use FS descriptors (currently uses .Source).
internal/cli/kraft/run/runner_kraftfile_runtime.go Uses runtime query/reference helpers for catalog lookups.
internal/cli/kraft/run/run.go Switches rootfs-type flag plumbing to v0.7 FS type.
internal/cli/kraft/pkg/pull/pull.go Avoids nil deref by caching template pointer; respects v0.7 template semantics.
internal/cli/kraft/pkg/pkg.go Switches rootfs-type option type to v0.7 FS type.
internal/cli/kraft/pkg/packager_kraftfile_runtime.go Propagates ROM FS descriptors through packaging + ROM build.
internal/cli/kraft/menu/menu.go Avoids nil deref when template is unavailable/merged.
internal/cli/kraft/fetch/fetch.go Avoids nil deref when template is unavailable/merged.
internal/cli/kraft/cloud/deploy/deploy.go Switches rootfs-type option type to v0.7 FS type.
internal/cli/kraft/cloud/compose/up/up.go Switches rootfs-type option type to v0.7 FS type.
internal/cli/kraft/cloud/compose/build/build.go Switches rootfs-type option type to v0.7 FS type.
internal/cli/kraft/build/builder_kraftfile_runtime.go Uses runtime ref helpers; improves error messages for lookup failures.
internal/cli/kraft/build/build.go Honors project outdir for initrd/kernel output paths; switches rootfs-type option type.
initrd/rootfs.go Changes ROM builder to work on FS descriptors and honor per-ROM/default fs type.
initrd/options.go Replaces initrd FsType with kraftfile v0.7 FsType; updates enums.
initrd/file.go Updates fs type detection return type.
go.mod Adds unikraft.com/x/kraftfile and pins sigs.k8s.io/yaml.
go.sum Updates module checksums for new dependencies.
Makefile Updates formatting target to use golangci-lint’s formatter command.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread initrd/options.go
Comment thread internal/cli/kraft/pkg/pkg.go Outdated
Comment thread unikraft/app/template_resolver.go
Comment thread internal/cli/kraft/run/run.go Outdated
Comment thread internal/cli/kraft/run/run.go Outdated
@ijaidev
Copy link
Copy Markdown
Contributor Author

ijaidev commented Apr 27, 2026

just one comment my side, otherwise looks pretty good

needs thorough testing though 😅

just one comment my side, otherwise looks pretty good

needs thorough testing though 😅

I have done decent testing, but I totally agree with you, it needs thorough testing before merging into upstream

What should be the next step? more manual testing, or we should write some e2e tests parallel to the legacy parser

@ijaidev ijaidev force-pushed the kraftfile-schema07-support branch from a4facbe to 19cb8a3 Compare April 27, 2026 11:02
ijaidev added 6 commits April 27, 2026 11:48
Add the Kraftfile v0.7 parser dependency and the YAML helper it
uses so later loader changes can compile against the new schema
package.

Signed-off-by: Jaidev <himjaidev@gmail.com>
Track which loader produced an application and reject Save,
AddLibrary, and RemoveLibrary for non-legacy projects so the
new v0.7 loader stays read-only.

Signed-off-by: Jaidev <himjaidev@gmail.com>
Split project loading by Kraftfile spec version and add the
first v0.7 document mapper for name, core, libraries, targets,
rootfs, volumes, and loader metadata.

Signed-off-by: Jaidev <himjaidev@gmail.com>
Keep full registry and digest runtime references intact during
parsing and query package catalogs with the derived name and
version fields used by build and run.

Signed-off-by: Jaidev <himjaidev@gmail.com>
Resolve v0.7 templates before converting the document into the
Application model so template defaults merge once and project
fields continue to win.

Signed-off-by: Jaidev <himjaidev@gmail.com>
Normalize target artifact names with the shared project-name
helper and reuse the configured project output directory when
build moves kernel and initramfs artifacts.

Signed-off-by: Jaidev <himjaidev@gmail.com>
@ijaidev ijaidev force-pushed the kraftfile-schema07-support branch from 19cb8a3 to ae9a157 Compare April 27, 2026 12:05
ijaidev added 2 commits April 27, 2026 12:25
Carry rootfs and ROM filesystem descriptors through app
loading, initrd generation, packaging, OCI emission, and CLI
flag parsing so v0.7 filesystem metadata is preserved end to
end.

Signed-off-by: Jaidev <himjaidev@gmail.com>
Change the fmt target to use $(GOCILINT) fmt instead of $(GOCILINT) format
as the correct sub-command is fmt.

Signed-off-by: Jaidev <himjaidev@gmail.com>
@ijaidev ijaidev force-pushed the kraftfile-schema07-support branch from ae9a157 to 1e4e962 Compare April 27, 2026 12:25
@craciunoiuc
Copy link
Copy Markdown
Member

Gomod is dirty 🙏

we should write some e2e tests parallel to the legacy parser

I think try to think of some other unit tests you could add for it. Basically hardcode some kraftfiles and test that it parses them correctly.

Include also some v0.6 kraftfiles in there. In general I think you can fetch some from unikraft/catalog and unikraft-cloud/examples (some older commits) for some real life examples.

I'll try to do some manual testing also of it to gain some confidence in it :D

Copy link
Copy Markdown
Member

@craciunoiuc craciunoiuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some other comments my side meanwhile


// WithRoms sets the application's auxiliary read-only memory blobs.
func WithRoms(roms ...string) ApplicationOption {
// WithRomFilesystems sets the application's ROM filesystem descriptors.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// WithRomFilesystems sets the application's ROM filesystem descriptors.
// WithRoms sets the application's ROM filesystem descriptors.

type ProjectLoader string

const (
ProjectLoaderLegacy ProjectLoader = "legacy"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not call it legacy here and in all places

It's actually v0.6, though it's not as standardised

Comment thread unikraft/app/project.go
uk := &unikraft.Context{
UK_NAME: name,
UK_BASE: popts.RelativePath(workdir),
UK_BASE: popts.workdir,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path no longer relative here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🧊 Icebox

Development

Successfully merging this pull request may close these issues.

3 participants